package com.kevin.hw.curator;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

/**
 * @author: kevin
 * @date: 2017/8/14
 * @description:
 */
public class CuratorClientConnect {

    private static CuratorFramework curatorFramework;

    private final static String CONNECT_HOST = "localhost:2181";

    public static CuratorFramework getInstance(){

        //curatorFramework = CuratorFrameworkFactory.newClient(CONNECT_HOST,5000,5000,new ExponentialBackoffRetry(1000,3));

        curatorFramework = CuratorFrameworkFactory
                .builder()
                .connectString(CONNECT_HOST)
                .retryPolicy(new ExponentialBackoffRetry(1000,3))
                .namespace("curator").build();

        curatorFramework.start();
        System.out.println("curatorFramework start success");

        return curatorFramework;
    }
}
